# 练习 9.8：权限 编写⼀个名为 Privileges 的类，它只有⼀个属性
# privileges，其中存储了练习 9.7 所述的字符串列表。将⽅法
# show_privileges() 移到这个类中。在 Admin 类中，将⼀个
# Privileges 实例⽤作其属性。创建⼀个 Admin 实例，并使⽤⽅法
# show_privileges() 来显⽰权限。


from  user import User

class Privileges:
    def __init__(self, privileges, username):
        self.privileges = privileges
        self.username = username

    def show_privileges(self):
        print("The privileges of " + self.username + " are: ")
        for privilege in self.privileges:
            print("-" + privilege)


class Admin(User):
    def __init__(self, username):
        super().__init__(username)
        self.privileges = Privileges(["can add post", "can delete post", "can ban user"], username)


